package cn.fl.warrant.service.impl;

import java.util.ArrayList;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cmm.mid.core.framework.page.KeyValueVO;
import cmm.mid.core.framework.page.Pager;
import cmm.user.facade.system.dto.SysUsrDTO;
import cn.cmm.base.framework.constant.BaseConstant;
import cn.cmm.base.framework.exception.BaseException;
import cn.cmm.base.framework.utils.BaseLogUtils;
import cn.cmm.base.framework.utils.CollectionUtils;
import cn.cmm.base.framework.utils.StringUtils;
import cn.fl.framework.base.context.CurrentThreadContext;
import cn.fl.warrant.service.IArcTransferDetailService;
import cn.fl.warrant.transform.ArcSysFlowSHVOTransform;
import cn.fl.warrant.transform.ArcTransferDetailVOTransform;
import cn.fl.warrant.vo.ArcSysFlowSHVO;
import cn.fl.warrant.vo.ArcTransferDetailVO;
import fl.flow.facade.flow.condition.SysFlowSHQueryCondition;
import fl.flow.facade.flow.dto.SysFlowSHDTO;
import fl.warrant.facade.archive.api.IArcTransferDetailApiService;
import fl.warrant.facade.archive.condition.ArcApplyMainQC;
import fl.warrant.facade.archive.condition.ArcTransferDetailQueryCondition;
import fl.warrant.facade.archive.constant.ArchiveConstants;
import fl.warrant.facade.archive.dto.ArcApplyMainDTO;
import fl.warrant.facade.archive.dto.ArcTransferDetailDTO;

/**
 * @Description: 移交申请明细表(旧表：T_API_DOCUMENT_TRANSFER_DETAIL) 客户端服务层接口实现
 * @Description: 业务层方法名称前缀：新增：add* 删除：remove* 修改：modify* 查询对象：select* get* 批量：batch* 查询集合：search*
 */
@Service
public class ArcTransferDetailServiceImpl implements IArcTransferDetailService {

	/**
	 * 日志
	 */
	private static final Logger logger = LoggerFactory.getLogger(IArcTransferDetailService.class);
	@Autowired
	private IArcTransferDetailApiService arcTransferDetailApiService;//移交申请明细表
	
	/**
	 * TODO 自定义 API 暴露服务
	 */
	//@Autowired
	//private I自定义ApiService 自定义ApiService;

	@Override
	public ArcTransferDetailVO selectById(Long id) throws BaseException{
		if(StringUtils.isEmpty(id)){
			BaseLogUtils.info(logger, "selectById", "主键参数不能为空!", CurrentThreadContext.getCurrentUserName());
			return null;
		}
		//TODO 业务逻辑
		ArcTransferDetailDTO dto = this.arcTransferDetailApiService.selectById(id);
		return ArcTransferDetailVOTransform.toVO(dto);
	}

	@Override
	public Long add(ArcTransferDetailVO entity) throws BaseException{
		if(null == entity){
			BaseLogUtils.info(logger, "add", "新增对象不能为空!", CurrentThreadContext.getCurrentUserName());
			return null;
		}
		return this.arcTransferDetailApiService.add(ArcTransferDetailVOTransform.toDTO(entity));
		
	}

	@Override
	public boolean removeById(Long id) throws BaseException{
		if(StringUtils.isEmpty(id)){
			BaseLogUtils.info(logger, "removeById", "删除主键参数不能为空!", CurrentThreadContext.getCurrentUserName());
			return false;
		}
		return this.arcTransferDetailApiService.removeById(id);
		
	}
	
	/**
     * 删除
     * @param ids
     * @return
     */
    public boolean removeByIds(List<Long> ids)throws BaseException{
    	if(CollectionUtils.isEmpty(ids)){
    		BaseLogUtils.info(logger, "removeByIds", "删除主键参数集合不能为空!", CurrentThreadContext.getCurrentUserName());
			return false;
		};
		return false;
    }

	@Override
	public boolean modify(ArcTransferDetailVO entity) throws BaseException{
		if(null == entity){
			BaseLogUtils.info(logger, "modify", "修改对象参数不能为空!", CurrentThreadContext.getCurrentUserName());
			return false;
		}
		return this.arcTransferDetailApiService.modify(ArcTransferDetailVOTransform.toDTO(entity));
		
	}

	@Override
	public Pager searchListPage(Pager page) throws BaseException{
		if(null == page)page = new Pager();
		return this.arcTransferDetailApiService.searchListPage(page);
		
	}
	@Override
	public List<ArcTransferDetailVO> searchList(ArcTransferDetailQueryCondition qc ){
		String syscd=CurrentThreadContext.getCurrentSysCd() ;
		String orgcd=CurrentThreadContext.getCurrentOrgCd();
		return ArcTransferDetailVOTransform.toVOList(this.arcTransferDetailApiService.searchList(qc, syscd, orgcd));
	}

}
